/*
 * @Author: chen haoxuan
 * @Date: 2021-05-29 21:29:26
 * @LastEditTime: 2021-05-29 21:44:04
 */
#include<iostream>
using namespace std;
class Student         // 声明基类
{
  public:
    void get_value()
    {
      cin>>num>>name>>sex;
    }
    void display()
    {
      cout<<"num: "<<num<<endl;
      cout<<"name: "<<name<<endl;
      cout<<"sex: "<<sex<<endl;
    }
  private:
    int num;
    string name;
    char sex;
};
class Student1:public Student
{
  public:
    void get_value1()
    {
      cin>>age>>addr;
    }
    void display_1()
    {
      // cout<<"num: "<<num<<endl;      引用基类的私有成员 错误
      // cout<<"name: "<<name<<endl;    引用基类的私有成员 错误
      // cout<<"sex: "<<sex<<endl;      引用基类的私有成员 错误
      cout<<"age: "<<age<<endl;
      cout<<"address: "<<addr<<endl;
    }
  private:
    int age;
    string addr;
};
int main()
{
  Student1 s1;
  s1.get_value();
  s1.get_value1();
  s1.display();
  s1.display_1();
  system("pause");
}
// 公有继承
/*
    派生类继承父类的公有成员，派生类不能直接访问基类的私有成员，只能通过基类的公有成员函数来访问基类的私有数据。
*/